//
//  CRPageView.h
//  TestPrj
//
//  Created by 朱铅峰 on 2020/8/4.
//  Copyright © 2020 Xing. All rights reserved.
//

#import <UIKit/UIKit.h>
@class CRPageView;

@protocol CRPageViewDataSource <NSObject>
- (NSInteger)numberOfPages:(CRPageView *)pageView;
- (UIView *)pageView:(CRPageView *)pageView viewInPage: (NSInteger)index;
@end

@protocol CRPageViewDelegate <NSObject>
@optional
- (void)pageViewScrollEnd:(CRPageView *)pageView
             currentIndex:(NSInteger)index
               totolPages:(NSInteger)pages;

- (void)pageViewDidScroll:(CRPageView *)pageView;
- (BOOL)needScrollAnimation;
@end


@interface CRPageView : UIView<UIScrollViewDelegate>
@property (nonatomic,strong)    UIScrollView   *scrollView;
@property (nonatomic,weak)    id<CRPageViewDataSource>  dataSource;
@property (nonatomic,weak)    id<CRPageViewDelegate>    pageViewDelegate;
- (void)scrollToPage: (NSInteger)pages;
- (void)reloadData;
- (UIView *)viewAtIndex: (NSInteger)index;
- (NSInteger)currentPage;


//旋转相关方法,这两个方法必须配对调用,否则会有问题
- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation
                                duration:(NSTimeInterval)duration;

- (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation
                                         duration:(NSTimeInterval)duration;

@end
